package com.yullage.ann.core;

import com.yullage.ann.common.ActivationFunction;

public class NormalNeuron extends Neuron {

	public NormalNeuron() {
		super();
		type = NeuronType.NORMAL;
	}

	/**
	 * Compute Sj = Wij * Aij + w0j * bias
	 */
	public void calculateOutput() {
		double s = 0;
		for (Connection con : inConnections) {
			Neuron fromNeuron = con.getFromNeuron();
			double weight = con.getWeight();
			double a = fromNeuron.getOutput(); // output from previous layer

			s = s + (weight * a);
		}

		output = g(s);
	}

	private double g(double x) {
		return ActivationFunction.bipolarContinuousFunction(x);
	}

}
